package com.ruoyi.quartz.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.quartz.domain.BaseBanner;
import com.ruoyi.quartz.service.IBaseBannerService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/base/banner")
public class BaseBannerController extends BaseController {

    @Resource
    private IBaseBannerService iBaseBannerService;

    @GetMapping("/list")
    public TableDataInfo list(BaseBanner baseBanner)
    {
        startPage();
        List<BaseBanner> list = iBaseBannerService.selectAll(baseBanner);
        return getDataTable(list);
    }

    @PostMapping
    public AjaxResult add(@RequestBody BaseBanner baseBanner) {
        return toAjax(iBaseBannerService.addBanner(baseBanner));
    }

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable Integer id)
    {
        return success(iBaseBannerService.selectBannerById(id));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BaseBanner baseBanner){
        return toAjax(iBaseBannerService.updateBanner(baseBanner));
    }

    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids){
        iBaseBannerService.deleteBannerByIds(ids);
        return success();
    }


}
